package sysUtil

import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import sysAuth.SysUsers


/**
 * Created by Administrator on 2019-03-19.
 * 解析页面dom
 */
class JsoupUtil {

    /**
     * xxd ，根据table-field绑定的select，生成填报使用的select组件
     * @param xdTableColId
     */
    static getTianBaoBingdingHtml(xdTableColId){
        def select = ""
        try {

        }catch (Exception e){
            println "生成填报组件：select 异常.............."
            select = ""
            e.printStackTrace()
        }
        return String.valueOf(select)
    }

    /**
     * 根据dom-html生成jsoup实例
     * @param dom
     * @return
     */
    static getJsoupInstanceFromDom(dom){
        Document doc = Jsoup.parseBodyFragment(String.valueOf(dom));
        Element element =  doc.body()
        return element
    }

    static sysLicenceValid( ){
        def initDate = SysUsers.list().dateCreated.min()
        Calendar calendar = Calendar.getInstance()
        calendar.setTime(initDate)
        calendar.add(Calendar.DAY_OF_YEAR,60)
        def a = calendar.getTimeInMillis()
        def b = System.currentTimeMillis()
        return  a > b ?  Math.round ((a-b)/(24*60*60*1000)) : 0
    }
}
